﻿using System;
using System.Text;

namespace HslCommunication.WebSocket
{
	/// <summary>
	/// websocket 协议下的单个消息的数据对象<br />
	/// Data object for a single message under the websocket protocol
	/// </summary>
	// Token: 0x02000023 RID: 35
	public class WebSocketMessage
	{
		/// <summary>
		/// 是否存在掩码<br />
		/// Whether a mask exists
		/// </summary>
		// Token: 0x17000084 RID: 132
		// (get) Token: 0x06000241 RID: 577 RVA: 0x00008EDC File Offset: 0x000070DC
		// (set) Token: 0x06000242 RID: 578 RVA: 0x00008EE4 File Offset: 0x000070E4
		public bool HasMask { get; set; }

		/// <summary>
		/// 当前的websocket的操作码<br />
		/// The current websocket opcode
		/// </summary>
		// Token: 0x17000085 RID: 133
		// (get) Token: 0x06000243 RID: 579 RVA: 0x00008EED File Offset: 0x000070ED
		// (set) Token: 0x06000244 RID: 580 RVA: 0x00008EF5 File Offset: 0x000070F5
		public int OpCode { get; set; }

		/// <summary>
		/// 负载数据
		/// </summary>
		// Token: 0x17000086 RID: 134
		// (get) Token: 0x06000245 RID: 581 RVA: 0x00008EFE File Offset: 0x000070FE
		// (set) Token: 0x06000246 RID: 582 RVA: 0x00008F06 File Offset: 0x00007106
		public byte[] Payload { get; set; }

		/// <inheritdoc />
		// Token: 0x06000247 RID: 583 RVA: 0x00008F0F File Offset: 0x0000710F
		public override string ToString()
		{
			return string.Format("OpCode[{0}] HasMask[{1}] Payload: {2}", this.OpCode, this.HasMask, Encoding.UTF8.GetString(this.Payload));
		}
	}
}
